package com.qf.smartplatform.dto;

import com.qf.smartplatform.valigroup.insert;
import com.qf.smartplatform.valigroup.select;
import lombok.Data;
import lombok.ToString;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotEmpty;

@Data
@ToString
public class UserDto {
    @NotEmpty(message = "用户名不能为空",groups = {select.class, insert.class})
    private String username;
//    @Length(min = 6, max = 10 ,message = "{\"code\": "+ ResultCode.PARAM_CONTENT_PARTTEN_ERROR +",\"msg\": \"密码长度6-10\"}", groups ={login.class, regist.class})
    private String password;
//    @NotEmpty(message = "名字不能为空",groups = { regist.class})
    private String name;
//    @Pattern(regexp = "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$", groups = regist.class,message = "{\"code\": "+ ResultCode.PARAM_CONTENT_PARTTEN_ERROR +",\"msg\": \"手机号错误\"}")
    private String phone;
//    @Pattern(regexp = "^\\w+@[\\da-z\\.-]+\\.([a-z]{2,6}|[\\u2E80-\\u9FFF]{2,3})$", groups = regist.class,message = "{\"code\": "+ ResultCode.PARAM_CONTENT_PARTTEN_ERROR +",\"msg\": \"邮箱错误\"}")
    private String email;
//    @NotEmpty(groups = {regist.class})
    private Long sex;
    public  boolean isEmpty(){
        System.out.println( !StringUtils.hasText(username)
                || !StringUtils.hasText(password)
                || !StringUtils.hasText(name)
                || !StringUtils.hasText(phone)
                || !StringUtils.hasText(email)
                || ObjectUtils.isEmpty(sex)
                || (sex != 0 & sex != 1));
        return !StringUtils.hasText(username)
                || !StringUtils.hasText(password)
                || !StringUtils.hasText(name)
                || !StringUtils.hasText(phone)
                || !StringUtils.hasText(email)
                || ObjectUtils.isEmpty(sex)
                || (sex != 0 & sex != 1);
    }
}
